package com.resume;

import com.resume.service.CityService;
import com.resume.service.CountryService;
import com.resume.service.ProvinceService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import sun.misc.Unsafe;

import javax.annotation.Resource;
import java.lang.reflect.Field;

@SpringBootApplication
public class ResumeApplication {

    public static void main(String[] args) {
        disableWarning();
        SpringApplication.run(ResumeApplication.class, args);
        //ctrl+alt+v：抽取变量
        //ctrl+alt+m：提取方法
    }


    // 解决警告：An illegal reflective access operation has occurred
    private static void disableWarning() {
        try {
            Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
            theUnsafe.setAccessible(true);
            Unsafe u = (Unsafe) theUnsafe.get(null);

            Class cls = Class.forName("jdk.internal.module.IllegalAccessLogger");
            Field logger = cls.getDeclaredField("logger");
            u.putObjectVolatile(cls, u.staticFieldOffset(logger), null);
        } catch (Exception e) {
            // ignore
        }
    }

    @Resource
    private ProvinceService provinceService;
    @Resource
    private CityService cityService;
    @Resource
    private CountryService countryService;

    /**
     * 初始化基础数据
     */
    private  void init(){
//        //应该是获取status可用的
//        //获取省份
//        ProvinceQuery provinceQuery = ProvinceQuery.builder().build();
//        List<Province> provinceList = provinceService.listProvince(provinceQuery);
//
//        //获取城市
//        CityQuery cityQuery = CityQuery.builder()
//                .provinceId(provinceList.get(0).getId())
//                .build();
//        List<City> cityList = cityService.listCity(cityQuery);
//
//        //获取县区
//        CountryQuery countryQuery = CountryQuery.builder()
//                .cityId(cityList.get(0).getId())
//                .build();
//        List<Country> countryList = countryService.listCountry(countryQuery);

    }

}
